using ASP;
using HoWave.Common;
using HoWave.Web;
using HoWave.Web.Shop;
using System;
using System.Data;
using System.IO;
using System.Text;
using System.Web;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class Shop_shopEdit : Shop, IRequiresSessionState
{
	protected PlaceHolder linkcss;
	protected PlaceHolder head1;
	protected Label PopularSearch;
	protected Repeater ReFriendLink;
	protected Label ProductRankName;
	protected Repeater ReShopRankList;
	protected Repeater RecommendationList;
	protected HiddenField HiddenLogo;
	protected HiddenField Hiddendianbiao;
	protected HiddenField HiddenBackGroundImage;
	protected HiddenField HiddenShopTitle;
	protected HiddenField HiddenShowType;
	protected HiddenField HiddenShopID;
	protected HiddenField HiddenMouldID;
	protected HiddenField HiddenCssID;
	protected HtmlForm form1;
	protected string FolderPath = "";
	protected int ShopID = 0;
	protected int MouldID = 0;
	protected int cssID = 0;
	protected string TemplateText = "";
	protected string WstrPrice = "";
	public string SeeWay = "";
	public string StrCss = "";
	public int TJImgHeight = 120;
	public int TJImgWidth = 120;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_PreInit(object sender, EventArgs e)
	{
		this.TemplateText = Template.GetTemplate(Template.GetTemplatePath("shopEdit"));
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.user.CheckUserLogin())
		{
			this.WriteErrMsg("", Language.GetMemberMsg("Common/NotLogin", new string[0]), this.InstallDir + "Passport/Login.aspx?ComeUrl=" + base.Server.UrlEncode(Fetch.CurrentUrl));
		}
		Shop_Shop shop_Shop = new Shop_Shop();
		if (Fetch.GetID("ShopID") > 0)
		{
			try
			{
				this.ShopID = int.Parse(base.Request.QueryString["ShopID"]);
			}
			catch (Exception ex)
			{
				this.ShopID = 0;
			}
		}
		else
		{
			this.ShopID = shop_Shop.GetShopIDByShopOwerID(base.user.UserID);
		}
		if (this.IsStorekeeper(this.ShopID, base.user.UserID))
		{
			if (this.ShopID == 0)
			{
				base.ClientScript.RegisterClientScriptBlock(typeof(Page), "", "<script>alert('无法装饰此店铺！')</script>");
			}
			else
			{
				this.TemplateText = this.TemplateText.Replace("{$ShopID}", this.ShopID.ToString());
				DataTable dataTable = this.conn.GetDataTable("select * from HLShop_Shop where ShopID=" + this.ShopID);
				if (dataTable != null && dataTable.Rows.Count > 0)
				{
					this.TemplateText = this.TemplateText.Replace("{$UserName}", dataTable.Rows[0]["ShopOwnerName"].ToString());
				}
				string a = base.Request.QueryString["tag"];
				if (a == "isSelect")
				{
					try
					{
						this.cssID = int.Parse(base.Request.QueryString["cssID"]);
					}
					catch (Exception ex)
					{
						ex.WriteErrorLog(new string[]
						{
							"正常操作"
						});
						this.cssID = 0;
					}
				}
				else
				{
					if (dataTable != null && dataTable.Rows.Count > 0)
					{
						try
						{
							this.cssID = int.Parse(dataTable.Rows[0]["cssID"].ToString());
						}
						catch (Exception ex)
						{
							ex.WriteErrorLog(new string[]
							{
								"正常操作"
							});
							this.cssID = 0;
						}
					}
				}
				this.HiddenLogo.Value = dataTable.Rows[0]["logoPath"].ToString();
				this.Hiddendianbiao.Value = dataTable.Rows[0]["ShopImageUrl"].ToString();
				this.HiddenShopTitle.Value = dataTable.Rows[0]["ShopName"].ToString();
				this.HiddenShowType.Value = dataTable.Rows[0]["ShowType"].ToString();
				this.HiddenBackGroundImage.Value = dataTable.Rows[0]["BackgroundImage"].ToString();
				this.TemplateText = this.TemplateText.Replace("{$CSSID}", this.cssID.ToString());
				this.HiddenCssID.Value = this.cssID.ToString();
				this.FolderPath = "EditCSS/css" + this.cssID.ToString();
				DirectoryInfo directoryInfo = new DirectoryInfo(base.Server.MapPath(this.FolderPath));
				FileSystemInfo[] fileSystemInfos = directoryInfo.GetFileSystemInfos();
				for (int i = 0; i < fileSystemInfos.Length; i++)
				{
					FileSystemInfo fileSystemInfo = fileSystemInfos[i];
					this.linkcss.Controls.Add(shop_Shop.ChangeSkin(this.FolderPath + "/" + Path.GetFileName(fileSystemInfo.FullName)));
				}
				this.HiddenShopID.Value = this.ShopID.ToString();
				this.HiddenMouldID.Value = this.MouldID.ToString();
				this.BindFriendLink();
				this.EditShop(this.ShopID);
				this.RankSorting(this.ShopID);
				this.Edit_GetProdcut_TJ(this.ShopID);
				try
				{
					Template.BindTextToPage(this.Page, this.TemplateText);
				}
				catch (Exception ex)
				{
					base.WriteTemErrMsg(ex.Message.ToString());
				}
			}
		}
	}
	public void BindFriendLink()
	{
		this.ReFriendLink.DataSource = this.conn.GetDataTable("select a.ShopID as SID,* from HLShop_FriendLink as a,HLShop_Shop as b where a.FriendUserId=b.ShopOwnerID and a.ShopID=" + this.ShopID);
		this.ReFriendLink.DataBind();
	}
	public bool IsStorekeeper(int ShopID, int UserID)
	{
		return this.conn.ExecuteCount(string.Concat(new object[]
		{
			"select count(*) from HLShop_Shop where ShopID=",
			ShopID,
			" and ShopOwnerID=",
			base.user.UserID
		})) > 0;
	}
	public void RankSorting(int ShopID)
	{
		DataTable dataSource = null;
		DataTable dataTable = this.conn.GetDataTable("select * from HLMall_StoreModule where ModuleID=1 and ShopID=" + ShopID);
		if (dataTable != null && dataTable.Rows.Count > 0)
		{
			DataRow dataRow = dataTable.Rows[0];
			int num = -1;
			int num2 = 0;
			decimal num3 = 0m;
			decimal num4 = 0m;
			string text = "";
			string text2;
			if (base.Request.QueryString["SeeWay"] != null)
			{
				if (SetGetCookies.Get("RankModuleName") != null)
				{
					this.ProductRankName.Text = SetGetCookies.Get("RankModuleName").Value;
				}
				else
				{
					this.ProductRankName.Text = dataRow["ModuleName"].ToString();
				}
				if (SetGetCookies.Get("RankClassID") != null)
				{
					try
					{
						num = int.Parse(SetGetCookies.Get("RankClassID").Value);
					}
					catch (Exception)
					{
						num = -1;
					}
				}
				else
				{
					num = int.Parse(dataRow["ClassID"].ToString());
				}
				if (SetGetCookies.Get("RankShowNum") != null)
				{
					try
					{
						num2 = int.Parse(SetGetCookies.Get("RankShowNum").Value);
					}
					catch (Exception ex)
					{
						ex.WriteErrorLog(new string[]
						{
							"正常操作"
						});
						num2 = 0;
					}
				}
				else
				{
					num2 = int.Parse(dataRow["ShowProductNum"].ToString());
				}
				if (SetGetCookies.Get("RankPrice1") != null)
				{
					try
					{
						num3 = decimal.Parse(SetGetCookies.Get("RankPrice1").Value);
					}
					catch (Exception ex)
					{
						ex.WriteErrorLog(new string[]
						{
							"正常操作"
						});
						num3 = 0m;
					}
				}
				else
				{
					num3 = decimal.Parse(dataRow["Pricerange1"].ToString());
				}
				if (SetGetCookies.Get("RankPrice2") != null)
				{
					try
					{
						num4 = decimal.Parse(SetGetCookies.Get("RankPrice2").Value);
					}
					catch (Exception ex)
					{
						ex.WriteErrorLog(new string[]
						{
							"正常操作"
						});
						num4 = 0m;
					}
				}
				else
				{
					num4 = decimal.Parse(dataRow["Pricerange2"].ToString());
				}
				if (SetGetCookies.Get("RankShowType") != null)
				{
					text2 = SetGetCookies.Get("RankShowType").Value;
				}
				else
				{
					text2 = dataRow["ShowType"].ToString();
				}
			}
			else
			{
				this.ProductRankName.Text = dataRow["ModuleName"].ToString();
				num = int.Parse(dataRow["ClassID"].ToString());
				num2 = int.Parse(dataRow["ShowProductNum"].ToString());
				num3 = decimal.Parse(dataRow["Pricerange1"].ToString());
				num4 = decimal.Parse(dataRow["Pricerange2"].ToString());
				text2 = dataRow["ShowType"].ToString();
			}
			if (base.Request.QueryString["RankTag"] != null)
			{
				text2 = base.Request.QueryString["RankTag"];
			}
			string text3 = text2;
			if (text3 != null)
			{
				if (!(text3 == "topSelling"))
				{
					if (text3 == "topCollect")
					{
						string text4 = " and a.EnableSale=1 and a.Stocks>0 and a.EnableSingleSell=1";
						object obj = text;
						text = string.Concat(new object[]
						{
							obj,
							" ShopID=",
							ShopID,
							text4
						});
						if (num != -1)
						{
							text = text + " and ClassID=" + num;
						}
						if (num3 != 0m && num4 != 0m)
						{
							obj = text;
							text = string.Concat(new object[]
							{
								obj,
								" and a.StandPrice>=",
								num3,
								" and a.StandPrice<=",
								num4
							});
						}
						text += " order by BuyTimes desc ";
						string text5 = " (select COUNT(*) from [HLShop_MyFavourite] where F_Type=0 and F_ProductID=a.ProductID) as BuyTimes,a.ProductID,a.ProductName,a.StandPrice,a.PUnit,a.ProductImageUrl,a.ProductSmallImageUrl,a.Stocks,a.ShopID,a.SalerID,a.ProductPlace,a.ProductNum,a.ClassID ";
						dataSource = this.conn.GetDataTable(string.Concat(new object[]
						{
							"select top ",
							num2,
							text5,
							"  from HLShop_Product as a where ",
							text
						}));
					}
				}
				else
				{
					string str = " and a.EnableSale=1 and a.Stocks>0 and a.EnableSingleSell=1";
					text = " DateDiff(MM,b.InputTime,getdate())=0 and b.OrderFormID=c.OrderFormID and a.ProductID=c.ProductID " + str;
					if (num != -1)
					{
						text = text + " and a.ClassID=" + num;
					}
					object obj;
					if (num3 != 0m && num4 != 0m)
					{
						obj = text;
						text = string.Concat(new object[]
						{
							obj,
							" and a.StandPrice>=",
							num3,
							" and a.StandPrice<=",
							num4
						});
					}
					string text6 = ",(select sum(Quantity) from HLShop_OrderItem as e join HLShop_Order as d on e.ProductID=a.ProductID and  e.OrderFormNum=d.OrderFormNum  and d.Status=2) as BuyTimes";
					string text7 = " a.FavouriteNum,a.ProductID,a.ProductName,a.StandPrice,a.PUnit,a.ProductImageUrl,a.Stocks,a.ShopID,a.SalerID,a.ProductPlace,a.ProductNum,a.ClassID";
					obj = text;
					text = string.Concat(new object[]
					{
						obj,
						" and a.ShopID=",
						ShopID,
						" group by ",
						text7,
						",BuyTimes order by a.BuyTimes desc"
					});
					string sql = string.Concat(new object[]
					{
						"select top ",
						num2,
						text7,
						text6,
						" from HLShop_Product as a,HLShop_Order as b,HLShop_OrderItem as c where ",
						text
					});
					dataSource = this.conn.GetDataTable(sql);
				}
			}
			this.ReShopRankList.DataSource = dataSource;
			this.ReShopRankList.DataBind();
			text3 = text2;
			if (text3 != null)
			{
				if (!(text3 == "topSelling"))
				{
					if (text3 == "topCollect")
					{
						for (int i = 0; i < this.ReShopRankList.Items.Count; i++)
						{
							Panel panel = (Panel)this.ReShopRankList.Items[i].FindControl("pnltopSelling");
							Panel panel2 = (Panel)this.ReShopRankList.Items[i].FindControl("pnltopCollect");
							if (panel != null && panel2 != null)
							{
								panel.Attributes.Add("style", "display:none");
								panel2.Attributes.Add("style", "display:block");
							}
						}
					}
				}
				else
				{
					for (int i = 0; i < this.ReShopRankList.Items.Count; i++)
					{
						Panel panel = (Panel)this.ReShopRankList.Items[i].FindControl("pnltopSelling");
						Panel panel2 = (Panel)this.ReShopRankList.Items[i].FindControl("pnltopCollect");
						if (panel != null && panel2 != null)
						{
							panel.Attributes.Add("style", "display:block");
							panel2.Attributes.Add("style", "display:none");
						}
					}
				}
			}
		}
		dataTable.Dispose();
	}
	public void EditShop(int ShopID)
	{
		StringBuilder stringBuilder = new StringBuilder();
		string[] array;
		if (SetGetCookies.Get("ModuleID") != null)
		{
			array = SetGetCookies.Get("ModuleID").Value.Split(new char[]
			{
				','
			});
		}
		else
		{
			array = new string[0];
		}
		if (array.Length > 0)
		{
			for (int i = 0; i < array.Length; i++)
			{
				stringBuilder.Remove(0, stringBuilder.Length);
				string text = array[i];
				if (text != null)
				{
					if (!(text == "1"))
					{
						if (!(text == "5"))
						{
							if (!(text == "6"))
							{
								if (text == "7")
								{
									string text2 = "商品列表";
									if (SetGetCookies.Get("PLModuleName") != null)
									{
										text2 = HttpUtility.UrlDecode(SetGetCookies.Get("PLModuleName").Value);
									}
									string text3 = "";
									if (SetGetCookies.Get("PLKeyword") != null)
									{
										text3 = SetGetCookies.Get("PLKeyword").Value;
									}
									int num = -1;
									if (SetGetCookies.Get("PLSelectClassID") != null)
									{
										try
										{
											num = int.Parse(SetGetCookies.Get("PLSelectClassID").Value);
										}
										catch (Exception ex)
										{
											ex.WriteErrorLog(new string[]
											{
												"正常操作"
											});
											num = -1;
										}
									}
									int num2 = -1;
									if (SetGetCookies.Get("PLProductType") != null)
									{
										try
										{
											num2 = int.Parse(SetGetCookies.Get("PLProductType").Value);
										}
										catch (Exception ex)
										{
											ex.WriteErrorLog(new string[]
											{
												"正常操作"
											});
											num2 = -1;
										}
									}
									decimal num3 = 0m;
									decimal num4 = 0m;
									if (SetGetCookies.Get("PLPrice1") != null)
									{
										try
										{
											num3 = decimal.Parse(SetGetCookies.Get("PLPrice1").Value);
										}
										catch (Exception ex)
										{
											ex.WriteErrorLog(new string[]
											{
												"正常操作"
											});
											num3 = 0m;
										}
									}
									if (SetGetCookies.Get("PLPrice2") != null)
									{
										try
										{
											num4 = decimal.Parse(SetGetCookies.Get("PLPrice2").Value);
										}
										catch (Exception ex)
										{
											ex.WriteErrorLog(new string[]
											{
												"正常操作"
											});
											num4 = 0m;
										}
									}
									int num5 = 120;
									if (SetGetCookies.Get("PLpicSize") != null)
									{
										try
										{
											num5 = int.Parse(SetGetCookies.Get("PLpicSize").Value);
										}
										catch (Exception ex)
										{
											ex.WriteErrorLog(new string[]
											{
												"正常操作"
											});
											num5 = 120;
										}
									}
									int num6 = 10;
									if (SetGetCookies.Get("PLitemNum") != null)
									{
										try
										{
											num6 = int.Parse(SetGetCookies.Get("PLitemNum").Value);
										}
										catch (Exception ex)
										{
											ex.WriteErrorLog(new string[]
											{
												"正常操作"
											});
											num6 = 10;
										}
									}
									string text4 = "Humanspirit";
									if (SetGetCookies.Get("PLorderType") != null)
									{
										text4 = SetGetCookies.Get("PLorderType").Value;
									}
									stringBuilder.Append(string.Concat(new string[]
									{
										"Update HLMall_StoreModule set ModuleName='",
										text2,
										"',Keyword='",
										text3,
										"',"
									}));
									stringBuilder.Append(string.Concat(new object[]
									{
										"ClassID=",
										num,
										",ProductType=",
										num2,
										",Pricerange1=",
										num3,
										","
									}));
									stringBuilder.Append(string.Concat(new object[]
									{
										"Pricerange2=",
										num4,
										",Picturesize=",
										num5,
										",ShowProductNum=",
										num6,
										",Sortingway='",
										text4,
										"' where ModuleID=7 and ShopID=",
										ShopID
									}));
									try
									{
										this.conn.Execute(stringBuilder.ToString());
									}
									catch (Exception ex)
									{
										ex.WriteErrorLog(new string[0]);
									}
								}
							}
							else
							{
								int num7 = 1;
								if (SetGetCookies.Get("JlOrderByID") != null)
								{
									try
									{
										num7 = int.Parse(SetGetCookies.Get("JlOrderByID").Value);
									}
									catch (Exception ex)
									{
										ex.WriteErrorLog(new string[]
										{
											"正常操作"
										});
										num7 = 1;
									}
								}
								int num8 = 10;
								if (SetGetCookies.Get("JlShowPostsNum") != null)
								{
									try
									{
										num8 = int.Parse(SetGetCookies.Get("JlShowPostsNum").Value);
									}
									catch (Exception ex)
									{
										ex.WriteErrorLog(new string[]
										{
											"正常操作"
										});
										num8 = 10;
									}
								}
								try
								{
									this.conn.Execute(string.Concat(new object[]
									{
										"Update HLMall_StoreModule set PostsShowType=",
										num7,
										",ShowPostsNum=",
										num8,
										" where ModuleID=6 and ShopID=",
										ShopID
									}));
								}
								catch (Exception ex)
								{
									ex.WriteErrorLog(new string[0]);
								}
							}
						}
						else
						{
							int num9 = 120;
							int num10 = 6;
							string text5 = "NewOn";
							if (SetGetCookies.Get("ElitePicSize") != null)
							{
								try
								{
									num9 = int.Parse(SetGetCookies.Get("ElitePicSize").Value);
								}
								catch (Exception ex)
								{
									ex.WriteErrorLog(new string[]
									{
										"正常操作"
									});
									num9 = 120;
								}
							}
							if (SetGetCookies.Get("EliteProNum") != null)
							{
								try
								{
									num10 = int.Parse(SetGetCookies.Get("EliteProNum").Value);
								}
								catch (Exception ex)
								{
									ex.WriteErrorLog(new string[]
									{
										"正常操作"
									});
									num10 = 6;
								}
							}
							if (SetGetCookies.Get("EliteOrderBy") != null)
							{
								text5 = SetGetCookies.Get("EliteOrderBy").Value;
							}
							try
							{
								this.conn.Execute(string.Concat(new object[]
								{
									"Update HLMall_StoreModule set Picturesize=",
									num9,
									",ShowProductNum=",
									num10,
									",Sortingway='",
									text5,
									"' where ModuleID=5 and ShopID=",
									ShopID
								}));
							}
							catch (Exception ex)
							{
								ex.WriteErrorLog(new string[0]);
							}
						}
					}
					else
					{
						string text6 = "";
						if (SetGetCookies.Get("RankModuleName") != null)
						{
							text6 = HttpUtility.UrlDecode(SetGetCookies.Get("RankModuleName").Value);
						}
						int num11 = -1;
						if (SetGetCookies.Get("RankClassID") != null)
						{
							try
							{
								num11 = int.Parse(SetGetCookies.Get("RankClassID").Value);
							}
							catch (Exception ex)
							{
								ex.WriteErrorLog(new string[]
								{
									"正常操作"
								});
								num11 = -1;
							}
						}
						int num12 = 10;
						if (SetGetCookies.Get("RankShowNum") != null)
						{
							try
							{
								num12 = int.Parse(SetGetCookies.Get("RankShowNum").Value);
							}
							catch (Exception ex)
							{
								ex.WriteErrorLog(new string[]
								{
									"正常操作"
								});
								num12 = 10;
							}
						}
						decimal num13 = 0m;
						decimal num14 = 0m;
						if (SetGetCookies.Get("RankPrice1") != null)
						{
							try
							{
								num13 = decimal.Parse(SetGetCookies.Get("RankPrice1").Value);
							}
							catch (Exception ex)
							{
								ex.WriteErrorLog(new string[]
								{
									"正常操作"
								});
								num13 = 0m;
							}
						}
						if (SetGetCookies.Get("RankPrice2") != null)
						{
							try
							{
								num14 = decimal.Parse(SetGetCookies.Get("RankPrice2").Value);
							}
							catch (Exception ex)
							{
								ex.WriteErrorLog(new string[]
								{
									"正常操作"
								});
								num14 = 0m;
							}
						}
						string text7 = "本月热销排行";
						if (SetGetCookies.Get("RankShowType") != null)
						{
							text7 = SetGetCookies.Get("RankShowType").Value;
						}
						stringBuilder.Append(string.Concat(new object[]
						{
							"Update HLMall_StoreModule set ModuleName='",
							text6,
							"',ClassID=",
							num11,
							","
						}));
						stringBuilder.Append(string.Concat(new object[]
						{
							"ShowProductNum=",
							num12,
							",Pricerange1=",
							num13,
							",Pricerange2=",
							num14,
							","
						}));
						stringBuilder.Append(string.Concat(new object[]
						{
							"ShowType='",
							text7,
							"' where ModuleID=1 and ShopID=",
							ShopID
						}));
						try
						{
							this.conn.Execute(stringBuilder.ToString());
						}
						catch (Exception ex)
						{
							ex.WriteErrorLog(new string[0]);
						}
					}
				}
			}
		}
	}
	public void EditKeywords(int ShopID)
	{
		StringBuilder stringBuilder = new StringBuilder();
		string[] array;
		if (SetGetCookies.Get("ModuleID") != null)
		{
			array = SetGetCookies.Get("ModuleID").Value.Split(new char[]
			{
				','
			});
		}
		else
		{
			array = new string[0];
		}
		if (array.Length > 0)
		{
			for (int i = 0; i < array.Length; i++)
			{
				stringBuilder.Remove(0, stringBuilder.Length);
				string text = array[i];
				if (text != null)
				{
					if (text == "3")
					{
						string text2 = "";
						if (SetGetCookies.Get("Keyword") != null)
						{
							text2 = HttpUtility.UrlDecode(SetGetCookies.Get("Keyword").Value);
						}
						DataTable dataTable = this.conn.GetDataTable("select Keyword from HLMall_StoreModule where ModuleID=3 and ShopID=" + ShopID);
						if (dataTable != null && dataTable.Rows.Count > 0)
						{
							if (dataTable.Rows[0]["Keyword"] != null)
							{
								string str = dataTable.Rows[0]["Keyword"].ToString();
								text2 += str;
							}
						}
						try
						{
							this.conn.Execute(string.Concat(new object[]
							{
								"Update HLMall_StoreModule set Keyword='",
								text2,
								"' where ModuleID=3 and ShopID=",
								ShopID
							}));
						}
						catch (Exception ex)
						{
							ex.WriteErrorLog(new string[0]);
						}
					}
				}
			}
		}
		if (SetGetCookies.Get("Keyword") != null)
		{
			string text3 = "";
			string text4 = HttpUtility.UrlDecode(SetGetCookies.Get("Keyword").Value);
			if (text4 != "")
			{
				text3 = "热门：";
				string[] array2 = text4.Split(new char[]
				{
					','
				});
				for (int i = 0; i < array2.Length; i++)
				{
					object obj = text3;
					text3 = string.Concat(new object[]
					{
						obj,
						"<a href='ShopEdit.aspx?ShopID=",
						ShopID,
						"&ColumnTag=ProductList&SearchKey=",
						array2[i],
						"'>",
						array2[i],
						"</a>、"
					});
				}
			}
			DataTable dataTable = this.conn.GetDataTable("select * from HLMall_StoreModule where ModuleID=3 and ShopID=" + ShopID);
			if (dataTable != null && dataTable.Rows.Count > 0)
			{
				if (dataTable.Rows[0]["Keyword"] != null)
				{
					if (dataTable.Rows[0]["Keyword"].ToString() != "")
					{
						string[] array2 = dataTable.Rows[0]["Keyword"].ToString().Split(new char[]
						{
							','
						});
						for (int i = 0; i < array2.Length; i++)
						{
							object obj = text3;
							text3 = string.Concat(new object[]
							{
								obj,
								"<a href='ShopEdit.aspx?ShopID=",
								ShopID,
								"&ColumnTag=ProductList&SearchKey=",
								array2[i],
								"'>",
								array2[i],
								"</a>、"
							});
						}
					}
				}
			}
			this.PopularSearch.Text = text3.Substring(0, text3.Length - 1);
		}
		else
		{
			DataTable dataTable = this.conn.GetDataTable("select * from HLMall_StoreModule where ModuleID=3 and ShopID=" + ShopID);
			if (dataTable != null && dataTable.Rows.Count > 0)
			{
				if (dataTable.Rows[0]["Keyword"] != null)
				{
					if (dataTable.Rows[0]["Keyword"].ToString() != "")
					{
						string text3 = "热门：";
						string[] array2 = dataTable.Rows[0]["Keyword"].ToString().Split(new char[]
						{
							','
						});
						for (int i = 0; i < array2.Length; i++)
						{
							object obj = text3;
							text3 = string.Concat(new object[]
							{
								obj,
								"<a href='ShopEdit.aspx?ShopID=",
								ShopID,
								"&ColumnTag=ProductList&SearchKey=",
								array2[i],
								"'>",
								array2[i],
								"</a>"
							});
						}
						this.PopularSearch.Text = text3;
					}
				}
			}
			dataTable.Dispose();
		}
	}
	private void Edit_GetProdcut_TJ(int store_shopid)
	{
		string text = "";
		this.WstrPrice = " and (case when ProductType=3 and TeamNum=1 then TeamPrice1 when ProductType=3 and TeamNum=2 then TeamPrice2 ";
		this.WstrPrice += "  when ProductType=3 and TeamNum=3 then TeamPrice3 when ProductType=3 and TeamNum=4 then TeamPrice4";
		this.WstrPrice += "  when ProductType=3 and TeamNum=5 then TeamPrice5 else StandPrice end)";
		string text2 = "";
		decimal num = 0m;
		decimal num2 = 0m;
		if (base.Request.QueryString["KeyPrice1"] != null && base.Request.QueryString["KeyPrice2"] != null)
		{
			try
			{
				num = decimal.Parse(base.Request.QueryString["KeyPrice1"]);
				num2 = decimal.Parse(base.Request.QueryString["KeyPrice2"]);
			}
			catch (Exception ex)
			{
				ex.WriteErrorLog(new string[]
				{
					"正常操作"
				});
				num = 0m;
				num2 = 0m;
			}
		}
		if (base.Request.QueryString["SearchKey"] != null)
		{
			text2 = base.Request.QueryString["SearchKey"];
		}
		if (num != 0m && num2 != 0m)
		{
			object obj = text;
			text = string.Concat(new object[]
			{
				obj,
				this.WstrPrice,
				">=",
				num,
				this.WstrPrice,
				"<=",
				num2
			});
		}
		if (text2 != "")
		{
			text = text + " and ProductName like '%" + text2 + "%'";
		}
		DataTable dataTable = this.conn.GetDataTable("select * from HLMall_StoreModule where ModuleID=5 and ShopID=" + store_shopid);
		int num3 = 6;
		string text3 = " order by CreateTime desc";
		string text4;
		if (base.Request.QueryString["SeeWay"] != null)
		{
			if (SetGetCookies.Get("ElitePicSize") != null)
			{
				try
				{
					this.TJImgHeight = int.Parse(SetGetCookies.Get("ElitePicSize").Value);
					this.TJImgWidth = int.Parse(SetGetCookies.Get("ElitePicSize").Value);
				}
				catch (Exception ex)
				{
					ex.WriteErrorLog(new string[]
					{
						"正常操作"
					});
					this.TJImgHeight = 120;
					this.TJImgWidth = 120;
				}
			}
			else
			{
				try
				{
					this.TJImgHeight = int.Parse(dataTable.Rows[0]["Picturesize"].ToString());
					this.TJImgWidth = int.Parse(dataTable.Rows[0]["Picturesize"].ToString());
				}
				catch (Exception ex)
				{
					ex.WriteErrorLog(new string[]
					{
						"正常操作"
					});
					this.TJImgHeight = 120;
					this.TJImgWidth = 120;
				}
			}
			if (SetGetCookies.Get("EliteProNum") != null)
			{
				try
				{
					num3 = int.Parse(SetGetCookies.Get("EliteProNum").Value);
				}
				catch (Exception ex)
				{
					ex.WriteErrorLog(new string[]
					{
						"正常操作"
					});
					num3 = 6;
				}
			}
			else
			{
				try
				{
					num3 = int.Parse(dataTable.Rows[0]["ShowProductNum"].ToString());
				}
				catch (Exception ex)
				{
					ex.WriteErrorLog(new string[]
					{
						"正常操作"
					});
					num3 = 6;
				}
			}
			if (SetGetCookies.Get("EliteOrderBy") != null)
			{
				text4 = SetGetCookies.Get("EliteOrderBy").Value;
			}
			else
			{
				text4 = dataTable.Rows[0]["Sortingway"].ToString();
			}
		}
		else
		{
			try
			{
				this.TJImgHeight = int.Parse(dataTable.Rows[0]["Picturesize"].ToString());
				this.TJImgWidth = int.Parse(dataTable.Rows[0]["Picturesize"].ToString());
			}
			catch (Exception ex)
			{
				ex.WriteErrorLog(new string[]
				{
					"正常操作"
				});
				this.TJImgHeight = 120;
				this.TJImgWidth = 120;
			}
			try
			{
				num3 = int.Parse(dataTable.Rows[0]["ShowProductNum"].ToString());
			}
			catch (Exception ex)
			{
				ex.WriteErrorLog(new string[]
				{
					"正常操作"
				});
				num3 = 6;
			}
			text4 = dataTable.Rows[0]["Sortingway"].ToString();
		}
		string text5 = text4;
		if (text5 != null)
		{
			if (!(text5 == "NewOn"))
			{
				if (!(text5 == "Lowprice"))
				{
					if (text5 == "Hightprice")
					{
						text3 = " order by CurrentPrice desc ";
					}
				}
				else
				{
					text3 = " order by CurrentPrice asc ";
				}
			}
			else
			{
				text3 = " order by CreateTime desc ";
			}
		}
		string sql = string.Concat(new object[]
		{
			"select top ",
			num3,
			" * from HLShop_Product where IsElite=1 and EnableSingleSell=1 and EnableSale=1 and ShopID=",
			store_shopid,
			" ",
			text,
			text3
		});
		this.RecommendationList.DataSource = this.conn.GetDataTable(sql);
		this.RecommendationList.DataBind();
	}
	public string SubProductName(string ProductName, string type)
	{
		string text = ProductName;
		int num = 0;
		if (!(type == "list"))
		{
			if (type == "TJ")
			{
				num = this.TJImgWidth;
			}
		}
		if (num >= 220)
		{
			if (text.Length > 16)
			{
				text = text.Substring(0, 16) + "...";
			}
		}
		else
		{
			if (num >= 160)
			{
				if (text.Length > 11)
				{
					text = text.Substring(0, 11) + "...";
				}
			}
			else
			{
				if (text.Length > 9)
				{
					text = text.Substring(0, 9) + "...";
				}
			}
		}
		return text;
	}
}
